package cn.stylefeng.guns.core.common.exception;

import cn.stylefeng.roses.kernel.model.exception.AbstractBaseExceptionEnum;

public enum ApiExceptionEnum implements AbstractBaseExceptionEnum {
    SUCCESS(200,"请求成功"),

    /**
     * 字典
     */


    /**
     * 文件上传
     */


    /**
     * 权限和数据问题
     */


    /**
     * 账户问题
     */


    /**
     * 微信
     */
    WEIXIN_SET_ERROR(301,"微信配置有误"),
    WEIXIN_OPENID_ERROR(302,"获取用户信息出错"),


    /**
     * 错误的请求
     */
    REQUEST_NULL(202, "请求有错误"),
    SESSION_TIMEOUT(400, "会话超时"),
    SERVER_ERROR(500, "服务器异常"),

    /**
     * token异常
     */
    TOKEN_EXPIRED(700, "token过期"),
    TOKEN_ERROR(700, "token验证失败"),

    /**
     * 签名异常
     */
    SIGN_ERROR(700, "签名验证失败"),

    /**
     * 用户
     */
    AUTH_REQUEST_ERROR(400, "账号或密码错误"),
    USER_NOT_EXIT(401, "用户不存在"),
    USER_DISABLE(402,"用户已禁用"),
    USER_EXIT(403,"用户已存在"),
    VALIDATE_CODE_EXIT(405,"验证码已发送"),
    MESSAGE_SEND_ERROR(406,"验证码发送失败"),
    VALIDATE_CODE_ERROR(407,"验证码错误"),
    AGE_NOT_ALLOW(408,"年龄不在招生范围"),
    IDCARD_EXIT(409,"身份证已存在"),
    PHONE_EXIT(501,"手机号已存在"),
    PHONE_VALIDATE_ERROR(502,"手机号不正确"),
    IDCARD_VALIDATE_ERROR(503,"身份证不正确"),
    OPENID_NULL_ERROR(504,"用户信息错误"),
    MAJOR_SEX_NOT_ALLOW(601,"性别不允许"),

    /**
     *报名
     */

    SIGN_TIME_ERROR(600,"当前时间不允许报名"),
    SIGN_FULL(603,"课程已经报满了"),
    SIGN_REPET_ERROR(606,"您已报名该课程"),
    SIGN_COUNT_ERROR(605,"不允许超出学校规定班级数量"),
    SIGN_OVER_ERROR(602,"已报名"),
    SIGN_OUT_ERROR(601,"已过退班时间"),
    SIGN_OUT_PAY_ERROR(604,"已缴费，不允许退班"),
    SIGN_TIME_REPEAT_ERROR(601,"上课时间冲突"),
    SIGN_ONCE_ERROR(601,"已学该课程"),

    /**
     * 配置
     */
    CONGIF_PAY_ERROR(630,"支付配置错误"),
    PAY_TOTAL_ERROR(631,"金额错误"),
    PAY_API_ERROR(632,"支付调用出错"),
    HAS_PAY_ERROR(633,"您已经支付过了"),

    /**
     * 新闻
     */
    NEW_NULL_ERROR(640,"新闻已经不存在了"),

    /**
     *光大支付
     */
    GD_PAY_FAIL(650,"支付失败"),

    /**
     * 上传错误
     */
    NOT_SUPPORT_EXT(800,"不支持的文件格式"),
    FILE_SIZE_OUT(800,"超出图片大小限制"),
    OCR_IDCARD_ERROR(801,"识别身份证出错,请手动输入")
    ;


    ApiExceptionEnum(int code, String message) {
        this.code = code;
        this.message = message;
    }

    private Integer code;

    private String message;

    @Override
    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public static String getMessage(int code){
        for(ApiExceptionEnum e : ApiExceptionEnum.values()){
            if(e.getCode() == code){
                return e.getMessage();
            }
        }
        return null;
    }
}
